//
//  FlyLocalNotification.m
//  EnjoyShoppingStreet
//
//  Created by lifayu on 2017/11/9.
//  Copyright © 2017年 lifayu. All rights reserved.
//

#import "FlyLocalNotification.h"

static FlyLocalNotification *g_LocalNotification = nil;

@interface FlyLocalNotification ()

@property(nonatomic, strong) UILocalNotification *localNotification;

@end

@implementation FlyLocalNotification

+ (FlyLocalNotification *)defaultCenter {
    @synchronized(self) {
        if (nil == g_LocalNotification) {
            g_LocalNotification = [[[self class] alloc] init];
        }
    }
    
    return g_LocalNotification;
}

- (void)postLocalNotification:(NSString *)formatMessage userInfo:(NSDictionary *)userInfo
{
    if (nil == _localNotification)
    {
        _localNotification = [[UILocalNotification alloc] init];
    }
    NSDate *_fireDate = [NSDate date];
    _localNotification.timeZone = [NSTimeZone defaultTimeZone];
    _localNotification.repeatInterval = kCFCalendarUnitDay;
    
    _localNotification.alertAction = @"显示";
    _localNotification.alertBody = formatMessage;
    _localNotification.fireDate = _fireDate;
    _localNotification.userInfo = userInfo;
    
    [_localNotification setSoundName:UILocalNotificationDefaultSoundName];
    [[UIApplication sharedApplication] presentLocalNotificationNow:_localNotification];
}

@end
